/*
 * Copyright (c) 2023-2025 110476592@qq.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * @file draw_context.h
 * @brief 截图工具 
 * @author 110476592@qq.com 
 * @note   承接Qt项目外包定制开发。长期接收C++项目实训学徒,联系QQ：110476592。
 */

 
#ifndef DRAW_CONTEXT_H
#define DRAW_CONTEXT_H

#include <QColor>
#include <QDebug>

/**
  * @brief 绘图类型
  */
enum class PainterType {
    NA = 0,            ///< 什么都不做，等同与没有设置
    PENCIL = 1,        ///< 自由绘制，
    ARROW_LINE = 2,    ///< 绘制箭头，
    RECT = 3,          ///< 绘制矩形，
    CIRCLE = 4,        ///< 绘制圆形，
    BLUR = 5,          ///< 模糊
    MARKER = 6,        ///< 绘制马赛克
    LINE = 7,          ///< 绘制直线
    FILL_RECT = 8,     ///< 绘制实心矩形，


};

/**
 * @brief 绘图参数类，用于存储绘图所需的各种参数
 */
class DrawParam {
public:
  QColor m_color = "#52c41a"; ///< 颜色
  int   m_penSize = 2;        ///< 画笔线宽
  
  PainterType m_painterType =
      PainterType::NA;          ///< 当前的绘图类型,当前使用的绘图类型，默认值为 PainterType::NA，表示没有设置
};


/**
 * @brief 工作模式
 */
enum class  WorkMode{
    AREA_DRAW   = 1,         ///< 选区画图
    AREA_SELECT =2        ///< 设置选区
};

/**
 * @brief 绘图上下文
 * 该类提供了对绘图参数和工作模式的静态访问接口，用于统一管理绘图相关的配置信息。
 * 构造函数被删除，确保该类不能被实例化，只能通过静态方法访问其成员。
 */
class DrawContext {
  // 删除构造函数，防止实例化该类
  DrawContext() = delete;

public:
  /**
   * @brief 获取绘图参数的引用
   * @return 绘图参数对象的引用
   */
  static inline DrawParam &drawParam() { return s_drawParam; }

  /**
   * @brief 获取当前绘图颜色的引用
   * @return 当前绘图颜色的引用
   */
  static inline QColor &color() { return s_drawParam.m_color; }

  /**
   * @brief 设置当前绘图颜色
   * @param color 要设置的颜色
   */
  static inline void setColor(const QColor &color) {
    s_drawParam.m_color = color;
  }

  /**
   * @brief 获取当前画笔的线宽
   * @return 当前画笔的线宽
   */
  static inline int penSize() { return s_drawParam.m_penSize; }

  /**
   * @brief 设置当前画笔的线宽
   * @param width 要设置的画笔线宽
   */
  static inline void setPenSize(int width) {
    s_drawParam.m_penSize = width;
  }

  /**
   * @brief 获取当前使用的绘图类型
   * @return 当前使用的绘图类型
   */
  static inline PainterType painterType() {
    return s_drawParam.m_painterType;
  }

  /**
   * @brief 设置当前使用的绘图类型
   * @param id 要设置的绘图类型
   */
  static inline void setPainterType(PainterType id) {
    s_drawParam.m_painterType = id;
  }


public: 
  static DrawParam s_drawParam; ///< 绘图参数对象

};

#endif // DRAWCONTEXT_H
